﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NetDon.OA.Data.EntityClasses;
using NetDon.OA.Interface;
using NetDon.OA.Interface.eLogistics;
using NetDon.Utilities;

namespace NetDon.OA.Portal.Finance
{
    public partial class ConfirmInvoice : NavigationPageBase
    {


        protected IList<Guid> IssuingOrderIds
        {
            get
            {
                if (string.IsNullOrWhiteSpace(this.fieldIssuingOrderIds.Value))
                    return new List<Guid>();
                return this.fieldIssuingOrderIds.Value.Split(new char[] { ',' }).Select(id => id.ToGuid()).ToList();

            }
        }

        protected IList<Guid> RevenueMachineAccountIds
        {
            get
            {
                if (string.IsNullOrWhiteSpace(this.fieldRevenueMachineAccountIds.Value))
                    return new List<Guid>();
                return this.fieldRevenueMachineAccountIds.Value.Split(new char[] { ',' }).Select(id => id.ToGuid()).ToList();

            }
        }


        public decimal? StateofAccountAmount
        {
            get
            {
                if (string.IsNullOrWhiteSpace(this.fieldStateofAccountAmount.Value))
                    return null;
                return this.fieldStateofAccountAmount.Value.ToDecimal();

            }
        }



        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                CancelButton = btnCancel;

            }
        }


        protected void btnReLoadIds_Click(object sender, EventArgs e)
        {
            InvoiceInfoUC.LoadInitialData(IssuingOrderIds, RevenueMachineAccountIds, StateofAccountAmount);
            btnReLoadIds.Enabled = false;
        }



        protected void btnSave_Click(object sender, EventArgs e)
        {

            if (this.InvoiceInfoUC.SaveInvoice())
            {
                Success("保存成功！");
                this.CloseWindow(true);
            }

        }





    }
}